package eight.test_8_7;

import java.util.Scanner;

public class TestMain3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int xs = scanner.nextInt();
        int ys = scanner.nextInt();
        int xt = scanner.nextInt();
        int yt = scanner.nextInt();
        scanner.nextLine();
        char[][] arr = new char[n][m];
        for (int i = 0; i < n; i++) {
            String str = scanner.nextLine();
            char[] chars = str.toCharArray();
            arr[0] = chars;
        }
        int[][] dp = new int[n + 1][m + 1];
        for (int i = xs; i <= xt; i++) {
            for (int j = ys; j <= yt; j++) {
                if(dp[i - 1][j] == -1 && dp[i][j - 1] == -1) {
                    dp[i][j] = -1;
                } else if (dp[i - 1][j] != -1 && dp[i][j - 1] == -1) {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
    }
}
